package org.pb.basic.config;

import org.pb.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置类
 * @author pb
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login/**", "/verifycode/**", "/user/register/**", "/user/binder/**",
                "/swagger-resources/**", "/webjars/**", "/swagger-ui.html/**", "/fastdfs", "/shop/settlement")
                .excludePathPatterns("/notify"); // 放行notify请求
    }
}
